package com.xumt.hwHMSdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.xumt.hwHMSdemo.cannectSb.HttpRequest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Addaddress extends AppCompatActivity {
    private String result;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_addaddress);
        Button button=(Button)findViewById(R.id.simmitaddress);
        Intent intent=new Intent(this,Showaddress.class);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                addadress();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                startActivity(intent);

            }
        });
    }

    public void addadress(){
        EditText editText = findViewById(R.id.name);
        EditText editText1 = findViewById(R.id.phone);
        EditText editText2 = findViewById(R.id.address);
        String name = editText.getText().toString();
        String phone = editText1.getText().toString();
        String address = editText2.getText().toString();


        new Thread() {
            public void run() {
                try {
                    HttpRequest request = new HttpRequest();
                    result = request.sendGet("http://169.254.67.221:8081/address/addaddress",
                            "username=" + Login2.usernamen + "&" + "name=" + name
                                    + "&" + "phone=" + phone+ "&" + "address=" + address);

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }


}